package cn.structure.edp;

import cn.structure.ClassEntity;
import cn.structure.MethodEntity;

import java.util.Objects;

public class Recursion extends EdpEntity {
    private ClassEntity recursor;
    private MethodEntity operation;

    public Recursion(ClassEntity recursor, MethodEntity operation) {
        super();
        this.recursor = recursor;
        this.operation = operation;
    }

    public enum Role {
        recursor, operation
    }

    public ClassEntity getRecursor() {
        return recursor;
    }

    public void setRecursor(ClassEntity recursor) {
        this.recursor = recursor;
    }

    public MethodEntity getOperation() {
        return operation;
    }

    public void setOperation(MethodEntity operation) {
        this.operation = operation;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("Recursion{\n\t");
        sb.append("\n\t\"Recursor\":")
                .append(recursor);
        sb.append(",\n\t\"operation\":")
                .append(operation);
        sb.append("\n}");
        return sb.toString();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Recursion recursion = (Recursion) o;
        return Objects.equals(recursor, recursion.recursor) &&
                Objects.equals(operation, recursion.operation);
    }

    @Override
    public int hashCode() {
        return Objects.hash(recursor, operation);
    }
}
